package xyz.gzdxc.common.constant;

public enum ResultCode {
    // ------------------------ request success --------------------------------
    SUCCESS(200, "success"),

    // ------------------------ parameter validate fail 4xxxx --------------------------------
    /**
     * not login
     */
    UNAUTHORIZED(40100, "未登录"),

    /**
     * login timeout
     */
    OUT_TIME(40200, "登录超时"),

    /**
     * current user has no permission
     */
    FORBIDDEN(40300, "无权限"),

    /**
     * invalid session
     */
    INVALID_SESSION(40400, "会话失效"),

    /**
     * method not allowed
     */
    METHOD_NOT_ALLOWD(40500, "使用方法未对应上"),

    // ------------------------ business exception 5xxxx ---------------------------
    /**
     * parameter exception
     */
    PARAMETER_EXCEPTION(50010, "参数错误"),

    /**
     * parameter exception   email format exception
     */
    EMAIL_CODE_EXCEPTION(50011, "邮箱格式异常！"),

    /**
     * check code exception
     */
    CAPTCHA_EXCEPTION(50012, "验证码错误！"),

    /**
     * check code time out exception
     */
    CAPTCHA_TIME_OUT_EXCEPTION(50013, "验证码已失效！"),

    /**
     * user not exists or password not right
     */
    PWD_USER_EXCEPTION(50014, "用户不存在或密码错误！"),

    /**
     * server exception
     */
    SERVER_EXCEPTION(50200, "服务器异常"),

    /**
     * database
     * account exception
     */
    ACCOUNT_EXCEPTION(50031, "账号异常"),

    /**
     * database
     * account not exists
     */
    ACCOUNT_NOT_EXISTENT(50032, "用户不存在"),

    /**
     * database exception
     */
    DATABASE_EXCEPTION(50051, "数据库异常"),

    /**
     * data duplication
     */
    DATA_DUPLICATION(50080, "数据重复"),

    /**
     * record has existed
     */
    RECORD_CONFLICT(50081, "记录已存在"),

    /**
     * the record has a conflict with the history
     */
    HISTORY_CONFLICT(50082, "记录与历史记录有冲突"),

    // ------------------------ unknown exception 99999 --------------------------
    /**
     * unknown error，usually should not return this error，this kind of error should be processed by global error processing module
     */
    UNKNOWN(99999, "未知错误");

    /**
     * result code
     */
    private int retcode;

    /**
     * result message
     */
    private String msg;

    /**
     * constructor
     *
     * @param retcode result code
     * @param msg     result message
     */
    ResultCode(int retcode, String msg) {
        this.retcode = retcode;
        this.msg = msg;
    }

    public int getRetcode() {
        return retcode;
    }

    public void setRetcode(int retcode) {
        this.retcode = retcode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
